$(function () {
		// 首页轮播图
		function callSweiper(){
			MySweiper = new Swiper ('.indexBanner', {
			    // direction: 'vertical',
			    loop: true,
			    autoplay : 5000,
			    // 如果需要分页器
			    pagination: '.swiper-pagination',
			    // paginationClickable :true,
			     onInit: function(swiper){ //Swiper2.x的初始化是onFirstInit
			    	swiperAnimateCache(swiper); //隐藏动画元素 

			    	swiperAnimate(swiper); //初始化完成开始动画

			    }, 
			    onSlideChangeEnd: function(swiper){ 
				    swiperAnimate(swiper); //每个slide切换结束时也运行当前slide动画
				} 
			})  



		}
		// callSweiper();
	// 首页轮播图 end

	// 首页轮播图 请求
	$.ajax({
		url: severUrl+'index.php?m=Web&a=index',
		type: 'POST',
		dataType: 'JSONP'

	})
	.done(function(data) {
		console.log("success");
		console.log(data);
		bannerslides(data.slides);
		indexArticle(data.article);

		DocumentFun(data.Document);

		linksFun(data.link);

		PhotosFun(data.photo);


		figureFun(data.figure);



	})
	.fail(function(sre) {
		console.log("error");
		console.log(sre.statusText);
	})



	//轮播图

	function bannerslides(slides){
		console.log(slides);
		var IndBanerC = $('#IndBanerC');
		var html = '';

		for (var i = 0; i < slides.length; i++) {
			var cn = '<div class="swiper-slide">'+
			'<img src="'+slides[i].image_url+'">'+
			'<div class="banerWordCn">'+


			' <p class="ani ind1 " swiper-animate-effect="fadeInUp" swiper-animate-duration="0.5s" swiper-animate-delay="0.3s">'+slides[i].title+'</p>'+
			'<p class="ani ind2 " swiper-animate-effect="fadeInUp" swiper-animate-duration="0.5s" swiper-animate-delay="0.6s">'+slides[i].title2+'</p>'+
			' <p class="ani ind3" swiper-animate-effect="fadeInUp" swiper-animate-duration="0.5s" swiper-animate-delay="0.9s">'+slides[i].title3+'</p>'+
			'<a class="ani" swiper-animate-effect="fadeInUp" swiper-animate-duration="0.5s" swiper-animate-delay="1.2s" href="'+slides[i].url+'">Learm More</a>'+
			'</div>'+
			'</div>';
			html+=cn;
		}
		IndBanerC.html(html);
		callSweiper();

	}
//轮播图 end












// 文章和新闻

function indexArticle(Article){
        // var dari = ['JAN','FEB','MAR','APR','MAY','JUN','JUL','AUG','SEP','OCT','NOV','DEC'];
        var dari = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
        ArticleFun(Article[18]);
        FEATUREDFun(Article[22]);

        function ArticleFun(data){
        	var ANNList = $('#ANNList');
        	var html = '';
        	var moer = '<li class="clearfloat"><a href="articlelist.html?cate_id=18" class="bot">MORE</a> </li>';
        	var indOne = 0;
        	if (data.length >=5) {
        		indOne=4;
        	}else{
        		indOne = data.length-1;
        	}
        	for (var i = 0; i < indOne; i++) {
        		var issueDate = data[i].issueDate

        		var nian = (issueDate.split("-"))[0];
        		var yue = (issueDate.split("-"))[1];
        		var ri = (issueDate.split("-"))[2];

        		var cn = '<li class="clearfloat">'+
        		' <div class="timeCom">'+dari[(yue-1)] +' '+ri+', '+nian+'</div>'+
        		'<div class="RigCon">'+
        		'<a href="article.html?article_id='+data[i].article_id+'">'+
        		'<p>'+data[i].title+'</p>'+
        		// '<span>PRESS RELEASE</span>'+
        		'</a>'+
        		'</div>'+
        		'</li>';
        		html+=cn;
        	}
        	ANNList.html(html);
        }

        function FEATUREDFun(data){
        	var newsList = $('#newsList');
        	var html = '';
        	for (var j = 0; j <= 2; j++) {
        		var issueDate = data[j].issueDate
        		var nian = (issueDate.split("-"))[0];
        		var yue = (issueDate.split("-"))[1];
        		var ri = (issueDate.split("-"))[2];

        		var cn = '<li><a class="clearfloat" href="article.html?article_id='+data[j].article_id+'"><div class="imgc"><img src="'+data[j].image_url+'"><div class="hoverCn"><i class="iconfont">&#xe658;</i></div></div><div class="time">'+dari[(yue-1)] +' '+ri+', '+nian+'</div><div class="word">'+data[j].title+'</div></a></li>';


        		html+=cn;
        	}
        	newsList.html(html);
        }
    }

// 文章和新闻 end




//文件下载
function DocumentFun(data){
	var DocumensListNCn = $('#DocumensListNCn');
	var html = '';
	for (var i = 0; i <= 3; i++) {
		var cn = '<div class="swiper-slide"><a href="'+data[i].image_url+'">'+
		'<div class="DOCUL">'+
		'<div class="head">'+data[i].title+'</div>'+
		'<p>'+data[i].describe+'</p>'+
        '<div class="iconC"><i class="iconfont">&#xe64e;</i></div>'+
        
		'</div>'+
		'</a></div>';



		html+=cn;


	}
	DocumensListNCn.html(html);

	function DOWNLOADlist(){
		var DOWNLOADlist = new Swiper ('.swiper-DOWNLOADlist', {
			loop: true,

		})  
	}

	DOWNLOADlist();

}

//文件下载 end










//友情链接 link
    
function linksFun(data){
    var LinksCon = $('#LinksCon');
    var html = '';
    for (var i = 0; i < data.length; i++) {
         var cn = '<div class="swiper-slide"><a href="'+data[i].url+'"><img src="'+data[i].image_url+'"></a></div>';
        html+=cn;

           
    }
    LinksCon.html(html);

    function SubsidiariesList(){
	    var SubsidiariesList = new Swiper ('.SubsidiariesListCn', {
	        loop: true,
	        nextButton: '.swiper-button-next',
	        prevButton: '.swiper-button-prev',
	        slidesPerView : 'auto'

	    })  
	}
	SubsidiariesList();

}

//友情链接 link end







// 股票信息 
function STOCK_wordFun(){
	  $.ajax({
        url: severUrl+'index.php?m=Web&a=getStock',
        type: 'GET',
        dataType: 'JSONP'
    })
    .done(function(data) {
        console.log("success");
        console.log(data);
        $('#STOCK_word').find('.p2').text(data.time);
        $('#STOCK_word').find('.p3').text('HK＄'+data.g_price);
        $('#STOCK_word').find('.p4').text(isIfFun(data.isUp)+data.stock1+' | '+isIfFun(data.isUp)+data.stock2);
        function isIfFun(data){
            if (data > 0) {
                return '+ ';
            }else if (data < 0){
                return '- ';
            }else if(data == 0){
                return ' ';
            }
        }
    })
    .fail(function() {
        console.log("error");
    });
}

STOCK_wordFun();

// 股票信息  end





// figureFun
function figureFun(data){
    
    var FIGURESlist = $('#FIGURESlist');
    var html = '';
    for (var i = 0; i < data.length; i++) {

         var cn = '<div class="swiper-slide"><div class="came"><span id="counting-'+data[i].figure_id+'">'+parseInt(data[i].value)+'</span>'+ifType(data[i].type)+'</div><p class="name">'+expandEntities(data[i].title)+'</p></div>';
        html+=cn;
           
    }
    FIGURESlist.html(html);


    function ifType(type){
        if (type == "percent") {
            return '%';
        }else{
            return ' ';
        }
    }

    FIGURES(data);


      var mySwiper = new Swiper ('.swiper-containertwo', {
            freeMode:true,
            slidesPerView : 'auto'

        })  


}

// figureFun end



// 相册
  function PhotosFun(data){
    var photosNav = $('#photosNav');
    var html = '';
    console.log(data);
    for(var i in data){
        console.log(i);
        PhotosNavArray.push(i);
        var cn = '<div class="swiper-slide"><a href="javascript:void(0);" data-name="'+i+'">'+data[i].title+'</a></div>';
        html+=cn;

    }
    // console.log(PhotosNavArray);
    photosNav.html(html);
    photosNav.find('a').eq(0).addClass('active');

    PhotosObj = data;

    PhotosFunC(photosNav.find('a').eq(0).attr('data-name'));


     

  }
// 相册方法

function PhotosFunQie(){
    var photosNav = $('#photosNav');
    photosNav.on('click','a',function(){
        var string = $(this).attr('data-name');
        photosNav.find('a').removeClass('active');
        $(this).addClass('active');

        PhotosFunC(string)
    })
}

PhotosFunQie()


  function PhotosFunC(string){
    var photosCon = $('#photosCon');
    var data = PhotosObj[string].photo_list;
    html = '';
    for (var i = 0; i < 3; i++) {
        var cn = '<li>'+
                    '<a href="javascript:void(0);">'+
                        '<img class="photo" data-in="'+i+'" src="'+data[i].image_url+'">'+
                   ' </a>'+
                '</li>';

       
        html+=cn;
    }

    photosCon.html(html)


    // PhotosFrameFun();

    photosCon.on('click', 'li', function(event) {
        var li = photosCon.find('li');
        var dateimg = [];
        var index = $(this).index();

        for (var i = 0; i < li.length; i++) {
            dateimg.push(li.eq(i).find('img').attr('src'));
        }
        PhotoPreviewFun(dateimg,index);

    });

}

    

// 相册 end






})	




 //KEY FIGURES 数据 缓冲效果
 function FIGURES(data){
 	if ($('#FIGURESlist').length>0) {

 		var options = {
 			 useEasing : true,
 			  useGrouping : true,
 			  separator : '',
 			  decimal : '.',
 			  prefix : '',
 			  suffix : ''

 		};


 		$('#FIGURESlist').waypoint(function(){
 			var numAnim = new CountUp("counting-"+data[0].figure_id, 0, intedata(data[0].value,data[0].type), IfTyle(data[0].type), 3.5, options);
 			numAnim.start();
 			var numAnim = new CountUp("counting-"+data[1].figure_id, 0, intedata(data[1].value,data[1].type), IfTyle(data[1].type), 3.5, options);
 			numAnim.start();
 			var numAnim = new CountUp("counting-"+data[2].figure_id, 0, intedata(data[2].value,data[2].type), IfTyle(data[2].type), 3.5, options);
 			numAnim.start();
 			var numAnim = new CountUp("counting-"+data[3].figure_id, 0, intedata(data[3].value,data[3].type), IfTyle(data[3].type), 3.5, options);
 			numAnim.start();
 			var numAnim = new CountUp("counting-"+data[4].figure_id, 0, intedata(data[4].value,data[4].type), IfTyle(data[4].type), 3.5, options);
 			numAnim.start();
 		}, { offset: '100%' });
 	};

 	function IfTyle(type){
 		if (type== "fload") {
 			return 2;
 		}else{
 			return 0;
 		}
 	}

 	function intedata(int,type){
 		if (type == "fload") {
 			return parseFloat(int)
 		}else{
 			return parseInt(int);
 		}
 	}
 	
 }
// FIGURES()

 //KEY FIGURES 数据 缓冲效果 end